#ifndef __INA226_H
#define __INA226_H


//slaver address
#define Dev_Addr_Ina226_P24                  0x40  //ina226
#define Dev_Addr_Ina226_P12                  0x41  //ina226



#define IIC_ADDR(addr, flag)   ((addr << 1)|flag)

//flag 1:r    0:w
#define WRITE 0
#define READ 1

//register address
#define CFG_REG 0x00
#define SV_REG  0x01
#define BV_REG  0x02
#define PWR_REG 0x03
#define CUR_REG 0x04
#define CAL_REG 0x05

#define SHUNT_LSB       2.5f //
#define BUS_LSB         1.25f //mV
#define CUR_LSB         0.6f //mA
#define POW_LSB         (CUR_LSB*25) //mV

typedef struct
{
  float voltage;        //mv
  float current;        //mA
  float power;          //mW
  float pow_self;
  float battery;
  int current_outcnt;
}__attribute__((packed, aligned(1))) INA226;



void ina226_init(I2C_HandleTypeDef *hi2c,uint16_t DevAddress);
void Get_Voltage(I2C_HandleTypeDef *hi2c,uint16_t devaddr,INA226 *ina);
void Get_Current(I2C_HandleTypeDef *hi2c,uint16_t devaddr,INA226 *ina);
void Get_Power(I2C_HandleTypeDef *hi2c,uint16_t devaddr,INA226 *ina);
void get_ina226_power(I2C_HandleTypeDef *hi2c,uint16_t devaddr,INA226 *ina);
void Get_Power_Vol(INA226 *ina_p);
uint16_t Merge_Arr(uint8_t temp[2]);
void get_power_data(uint8_t proj_type, I2C_HandleTypeDef *hi2c,INA226 *ina);
void check_voltage_to_select_config( void );
#endif
